package com.example.mobile2121606109ycg0324;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    //全局控件变量声明
    private TextView tvMainTitle;
    private TextView tvMainPartID;
    private EditText edtTxtMainPartID;
    private Button btnMainBuy;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //调用初始化控件函数
        initView();
        btnMainBuy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int num = Integer.valueOf(edtTxtMainPartID.getText().toString());
                Log.i("TAG", "onClick: " + num);
            }
        });
    }

    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tvMainTitle);
        tvMainPartID = (TextView) findViewById(R.id.tvMainPartID);
        edtTxtMainPartID = (EditText) findViewById(R.id.edtTxtMainPartID);
        btnMainBuy = (Button) findViewById(R.id.btnMainBuy);
    }
}